package Eyjafjalla.card.skill;

import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.card.status.Burn_Eyjafjalla;
import Eyjafjalla.helper.EyjafjallaHelper;
import Eyjafjalla.patch.CloudPatch;
import Eyjafjalla.patch.MelodyPatch;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.common.MakeTempCardInHandAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

public class FlameMountain_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "FlameMountain_Eyjafjalla";
    private static final CardStrings cardStrings;

    public FlameMountain_Eyjafjalla(){
        super(ID, cardStrings.NAME,1,cardStrings.DESCRIPTION,CardType.SKILL,CardRarity.COMMON,CardTarget.SELF);
        this.baseBlock = 12;
        this.block = 12;
        this.baseMagicNumber = 2;
        this.magicNumber = 2;
        this.cardsToPreview = new Burn_Eyjafjalla();
        cardsToPreview.upgrade();
        setFireDescription(cardStrings.EXTENDED_DESCRIPTION[0]);
    }

    @Override
    public AbstractCard makeCopy() {
        return new FlameMountain_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new GainBlockAction(p,this.block));
        addToBot(new MakeTempCardInHandAction(cardsToPreview,1));
    }

    @Override
    protected void applyPowersToBlock() {
        int trueB = baseBlock;
        if(isFire()){
            baseBlock+=magicNumber* EyjafjallaHelper.countBurnCards();
        }
        super.applyPowersToBlock();
        baseBlock = trueB;
        isBlockModified = baseBlock!=block;
    }

    @Override
    public AbstractCard removeCardWhenObtained() {
        AbstractCard card = null;
        for(AbstractCard c: AbstractDungeon.player.masterDeck.group){
            if(c.cardID.equals(Defend_Eyjafjalla.ID)){
                card = c;
                break;
            }
        }
        return card;
    }

    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
            upgradeBlock(6);
            upgradeMagicNumber(1);
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}

